package mySQLServer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Link {
    private Connection con;
    private Statement stmt;
    public String sql;
    private ResultSet rs;
    public int flag=0;

    public Connection linkDatebase () throws SQLException,ClassNotFoundException{  //返回数据库的Connection
        String jdbc="com.microsoft.sqlserver.jdbc.SQLServerDriver";
        String url="jdbc:sqlserver://localhost:1433;DatabaseName=books_management";
        String user="sa";
        String password="admin";
        Class.forName(jdbc);
        Connection con=DriverManager.getConnection(url,user,password);
        return con;
    }

    public void closeDatebase(Connection con) throws SQLException{  //关闭数据库
        con.close();
    }


}


